package net.uman.framework.modules.utils;

import java.util.HashMap;
import java.util.Map;

import net.uman.framework.modules.log.Log;
import net.uman.framework.modules.log.SystemLog;
import net.uman.framework.modules.log.TraceLog;

/**
 * TraceLog provide service for programmer
 * SystemLog provide service for support/maintenance
 * Normally, call LoggerHelper.getTraceLog() 
 *   and LoggerHelper.getSystemLog() are sufficient  
 * @author Vitoe
 *
 */
public class LoggerHelper {

	private static Map mTraceMap = new HashMap();
	private static Map mSystemMap = new HashMap();

	public static TraceLog getTraceLog(String prefix){
		TraceLog traceLog = null;
		if(prefix==null) prefix = Log.LOG_TRACE;
		if(mTraceMap.get(prefix)!=null)
			return (TraceLog)mTraceMap.get(prefix);
		else{
			traceLog = new TraceLog();	
			mTraceMap.put(prefix, traceLog);
		}
		return traceLog;
	}	
	
	public static TraceLog getTraceLog(){
		return getTraceLog(Log.LOG_TRACE);
	}	
	
	public static TraceLog getChainStoreTraceLog(){
		return getTraceLog(Log.CHAINSTORE);
	}
	
	public static TraceLog getSupplierTraceLog(){
		return getTraceLog(Log.SUPPLIER);
	}
	
	public static TraceLog getLogisticsTraceLog(){
		return getTraceLog(Log.LOGISTICS);
	}
	
	public static TraceLog getSourcingTraceLog(){
		return getTraceLog(Log.SOURCING);
	}	
	
	public static TraceLog getChainHeadquarterTraceLog(){
		return getTraceLog(Log.CHAINHEADQUARTER);
	}
	
	public static SystemLog getSystemLog(String prefix){
		SystemLog SystemLog = null;
		if(prefix==null) prefix = Log.LOG_SYSTEM;
		if(mSystemMap.get(prefix)!=null)
			return (SystemLog)mSystemMap.get(prefix);
		else{
			SystemLog = new SystemLog();	
			mSystemMap.put(prefix, SystemLog);
		}
		return SystemLog;
	}	
	
	public static SystemLog getSystemLog(){
		return getSystemLog(Log.LOG_SYSTEM);
	}	
	
	public static SystemLog getChainStoreSystemLog(){
		return getSystemLog(Log.CHAINSTORE);
	}
	
	public static SystemLog getSupplierSystemLog(){
		return getSystemLog(Log.SUPPLIER);
	}
	
	public static SystemLog getLogisticsSystemLog(){
		return getSystemLog(Log.LOGISTICS);
	}
	
	public static SystemLog getSourcingSystemLog(){
		return getSystemLog(Log.SOURCING);
	}	
	
	public static SystemLog getChainHeadquarterSystemLog(){
		return getSystemLog(Log.CHAINHEADQUARTER);
	}

}
